package com.vcg.test;

import feign.springmvc.SpringMvcContract;
import feign.Feign;
import feign.gson.GsonDecoder;
import feign.gson.GsonEncoder;
import com.vcg.test.springmvc.Comment;
import com.vcg.test.springmvc.CommentService;

/**
 * Created by wuyu on 2016/6/10.
 */
public class HelloWorld {


    public static void main(String[] args) {

        CommentService commentService = Feign.builder()
                .encoder(new GsonEncoder())
                .decoder(new GsonDecoder())
                //如果是dubbox rest 可以使用 feign.jaxrs.JAXRSContract,需添加feign-jaxrs包
                .contract(new SpringMvcContract())
                .target(CommentService.class, "http://localhost:8080");

        Comment comment = commentService.get(1);
        System.err.println(comment.toString());

        Comment delete = commentService.delete(1);
        System.err.println(delete.toString());

        Comment update = commentService.update(new Comment(1, "更新"));
        System.err.println(update.toString());

        Comment add = commentService.add(new Comment(1, "添加"));
        System.err.println(add.toString());
    }

}
